<script type="text/javascript">
<!--
	function checkForm()
	{ldelim}
		if (jQuery.trim($('#m_name').val()) == '') {ldelim}
			alert('Bạn chưa nhập tên Modules');
			$('#m_name').focus();
			return false;
		{rdelim}
		if (jQuery.trim($('#m_disc').val()) == '') {ldelim}
			alert('Bạn chưa chú thích cho tên Modules');
			$('#m_disc').focus();
			return false;
		{rdelim}
		if (jQuery.trim($('#parent_id').val()) == '' || isNaN($('#parent_id').val())) {ldelim}
			alert('Bạn chưa Modules liên quan');
			$('#relation').focus();
			return false;
		{rdelim}
        if (jQuery.trim($('#m_tbl_struct').val()) != '' && jQuery.trim($('#m_tbl_name').val()) == '') {ldelim}
			alert('Bạn chưa nhập tên bảng');
			$('#m_tbl_name').focus();
			return false;
        {rdelim}
        // Kiem tra field sql

        if ($('#m_sql_create').is(':checked') == true) {ldelim}
    		if (checkFieldSQL() == false) {ldelim}
    			return false;
            {rdelim}

			if ($('#m_recursive:checked').val() == 'Y' && jQuery.trim($('#tbl_parent_id').val()) == '') {ldelim}
				alert('Bạn chưa nhập tên field parent id');
				return false;
			{rdelim}
    		if (jQuery.trim($('#tbl_pri_id').val()) == '') {ldelim}
    			alert('Bạn chưa nhập ID chính của bảng');
    			$('#tbl_pri_id').focus();
    			return false;
    		{rdelim}
    		if (jQuery.trim($('#tbl_pri_name').val()) == '') {ldelim}
    			alert('Bạn chưa nhập tên field chính của bảng');
    			$('#tbl_pri_name').focus();
    			return false;
    		{rdelim}
		{rdelim}
		return true;
	{rdelim}
	/**
	 * @function checkFieldSQL
	 *
	 */
	function checkFieldSQL()
	{ldelim}
        var chkReturn = true;
        var field_count = $('#total_field').val();
        if (field_count == 1) {ldelim}
          field_count = 2;
        {rdelim}
        var primaryKey = '';
        var tblName = $('#m_tbl_name').val();
        var sqlStr = 'CREATE TABLE `tbl_' + tblName + '` (\n';
        for(var i=1; i < field_count; i++) {ldelim}
          // chekc name field

          if ($('#field_name'+i).length) {ldelim}
            var fieldName = jQuery.trim($('#field_name' + i).val());
            if (fieldName == '') {ldelim}
              alert('Bạn chưa nhập Tên cho field');
              $('#field_name'+i).focus();
              chkReturn = false;
              break;
            {rdelim}
            if ($('#data_type' + i).val() == -1) {ldelim}
              alert('Bạn chưa chọn kiểu dữ liệu cho field');
              $('#data_type' + i).focus();
              chkReturn = false;
              break;
            {rdelim}
            // Ten field

            sqlStr += '                  `' + fieldName + '` '
            var dataType  = $('#data_type' + i).val();
            var dataLength = jQuery.trim($('#data_length' + i).val());

            // Kieu du lieu
            if ( ! (dataType && /^(text|longtext|blob|longblob|timestamp)$/.test(dataType))) {ldelim}
                if (dataLength == '' || dataLength == '--Length--') {ldelim}
                    alert('Bạn chưa nhập chiều dài cho kiểu dữ liệu');
                    $('#data_length' + i).focus();
                    chkReturn = false;
                    break;
                {rdelim}
                sqlStr += dataType + '(' + dataLength + ') ';

            {rdelim} else {ldelim}
                sqlStr += dataType + ' ';
            {rdelim}

            // COLLATE
            if (dataType && /^(enum|varchar|text|longtext|timestamp)$/.test(dataType)) {ldelim}
              sqlStr += 'COLLATE utf8_unicode_ci ';
            {rdelim}

            // unsigned
            var dataUnsign = $('#unsigned' + i).val();
            if (dataUnsign == 'Y') {ldelim}
              sqlStr += 'unsigned ';
            {rdelim}

            // Not Null
            var dataNotNull = $('#not_null' + i).val();
            if (dataNotNull == 'N') {ldelim}
              sqlStr += 'NOT NULL ';
            {rdelim}

            // Auto increment
            var dataAutoIncre = $('#auto_incr' + i).val();
            if (dataAutoIncre == 'Y') {ldelim}
              sqlStr += 'AUTO_INCREMENT ';
            {rdelim}

            // Gia tri default
            var defaultVal = jQuery.trim($('#data_default' + i).val());
            if (defaultVal != '' && defaultVal != '--Default value--' && dataAutoIncre == 'N') {ldelim}
                if (dataType == 'timestamp') {ldelim}
                    sqlStr += 'DEFAULT ' + defaultVal + ' ';
                {rdelim} else {ldelim}
                    sqlStr += 'DEFAULT ' + '\'' + defaultVal + '\' ';
                {rdelim}
            {rdelim}

            // commend
            var dataCommend = jQuery.trim($('#command' + i).val());
            if (dataCommend != '' && dataCommend != '--Command--') {ldelim}
              sqlStr += 'COMMENT \'' + dataCommend + '\'';
            {rdelim}
            sqlStr += ',\n';

            // primary key
            if ($('#primary' + i).val() == 'Y') {ldelim}
              primaryKey = fieldName;
            {rdelim}
          {rdelim}
        {rdelim}
        if (primaryKey != '') {ldelim}
          sqlStr += '  PRIMARY KEY (' + primaryKey + ')\n';
        {rdelim}
        sqlStr += ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;';
        // ket thuc kiem tra field sql
        if (chkReturn == false) {ldelim}
          return false;
        {rdelim}
        $('#m_tbl_struct').val(sqlStr);
	{rdelim}
	/**
	 * @function setParentId
	 *
	 * This fucntion will set parent value of module
	 */
	function setParentId(id)
	{ldelim}
		if (isNaN(id) || id < 0) {ldelim}
			$('#parent_id').val();
			return false;
		{rdelim}
		if (parseInt(id, 10) == 0) {ldelim}
			$('#relationDisp').show();
		{rdelim} else {ldelim}
			$('#relationDisp').hide();
		{rdelim}
		$('#parent_id').val(id);
	{rdelim}
	/**
	 * @function add item to form
	 *
	 */
	function addItemToForm()
	{ldelim}

	{rdelim}
	/**
	 * @function executeCancel
	 *
	 *
	 */
	function executeCancel()
	{ldelim}
		window.history.back(-1);
	{rdelim}
//-->

    //alert(appendId);
    function ajaxLoadField()
    {ldelim}
      var count = parseInt($('#total_field').val());
      if (count == 1) {ldelim}
        count = 2;
      {rdelim}
      var appendId = parseInt($('#total_field').val()) - 1;
      $.ajax({ldelim}
        type: "POST",
        url: <?php APPPATH ?> + '?c=modules&m=loadAjax',
        data: 'idx=' + count,
        success: function(data) {ldelim}
          count++;
          $('#total_field').val(count);
          if ($('#formField' + appendId).length) {ldelim}
            $('#formField' + appendId).append(data);
          {rdelim} else {ldelim}
            $('#formField').append(data);
          {rdelim}
        {rdelim}
      {rdelim});
    {rdelim}

    function ajaxDelField(id)
    {ldelim}
      if (confirm('Bạn có thật sự muốn xóa field này ?')) {ldelim}
        $('#formField' + id).remove();
      {rdelim}
    {rdelim}

    function showExpress(fid, id1, id2, id3)
    {ldelim}

      $('#' + id1).hide();
      $('#' + id2).hide();
	  $('#' + id3).hide();
      if ($('#' + fid).val() == 'TextArea') {ldelim}
        $('#' + id1).show();
      {rdelim} else if ($('#' + fid).val() == 'Text') {ldelim}
        $('#' + id2).show();
      {rdelim} else if ($('#' + fid).val() == 'File') {ldelim}
		$('#' + id3).show();
	  {rdelim}
    {rdelim}

	function showHideParent()
	{ldelim}
		if (document.getElementById('TBL_PARENT').style.display == 'none') {ldelim}
			$('#TBL_PARENT').show();
		{rdelim} else {ldelim}
			$('#TBL_PARENT').hide();
		{rdelim}
	{rdelim}
</script>
<div id="leftBox">
<div class="{$clsType}Box" style="display:{$msgBoxDisp}">
  <div class="{$clsType}BoxTop" style="display:{$msgBoxDisp}">&nbsp;</div>
  	{foreach from=$messages item=arrMsg}
    	{foreach from=$arrMsg item=msg}
    	<div class="msgBoxContent {$clsIcon}">
      	<p>{$msg}</p>
      	</div>
      {/foreach}
    {/foreach}
</div>
<form id="mainForm" name="mainForm" method="post" action="{$actionForm}">
<div class="contentBox" id="forms">
  <div class="contentBoxTop"><h3>Thêm / Chỉnh sửa Modules</h3><ul class="switcherTabs">
    </ul>
  </div>

      <div class="innerContent" id="box-1"><p><strong>Tên Modules</strong><em> (Chú ý khi thêm tên Modules)</em><br>
          <label class="smallInput">
          	<input name="m_name" id="m_name" value="{$module->m_name|escape}" style="width: 168px;" type="text">
          </label>
          </p>
          <p><strong>Tên Menu admin của Module</strong>
          <label class="smallInput">
          	<input name="m_name_view" id="m_name_view" value="{$module->m_name_view|escape}" style="width: 168px;" type="text">
          </label>
          </p>
          <p><strong>Chú thích Modules</strong><br>
          <label class="mediumInput">
          	<input name="m_disc" id="m_disc" value="{$module->m_discr|escape}" style="width: 377px;" type="text">
          </label>
          <br><strong>Modules liên quan</strong> (Module cha)<br>
		  <div>
          	<select id="relation" name="relation" onchange="setParentId(this.value)" style="width:180px;" {$dropListDisable}>
          		<option value="-1">-- Chọn modules --</option>
          		<option value="0" {$rootOpt}>&nbsp;&nbsp;&nbsp;Modules gốc  </option>
          		{$relationDropList}
          	</select>
		  </div>
		  <div id="relationDisp" style="display:{$mRelationDisp}">
		  <br><strong>Có Modules liên quan</strong>&nbsp;<input type="checkbox" name="m_relation" id="m_relation" value="Y" {$chkBox}><br>
		  </div>
		  <div style="display:{$otherRelation}">
		  	<br><strong>Module liên quan khác</strong><br>
              {foreach from=$arrModule item=row}
              <ul style="display:block;">
              	{foreach from=$row item=relamodule}
              	<li style="width:155px; float:left;">
              	  <label for="sm_name{$relamodule->m_id}">
              		<input name="sm_name[{$relamodule->m_id}]" id="sm_name{$relamodule->m_id}" value="{$relamodule->m_id}" type="checkbox" {$relamodule->checked}><a style="text-decoration:none;" title="{$relamodule->m_discr|escape}">{$relamodule->m_name|escape}</a>
              	  </label>
              	</li>
              	{/foreach}
              </ul>
              {/foreach}
		  </div>
		  <div style="clear:both;"></div>
		  <br><strong>Module quản lý trong admin</strong>&nbsp;<input type="checkbox" name="m_admin_disp" id="m_admin_disp" value="Y" {if $module->m_admin_disp == 'Y'}checked{/if}><br>
		  <br><strong>Tạo cấu trúc SQL</strong>&nbsp;<input type="checkbox" name="m_sql_create" id="m_sql_create" value="Y" {if $module->m_sql_create == 'Y'}checked{/if}><br>
		  <br><label for="m_multi_lang"><strong>Nhiều ngôn ngữ</strong></label>&nbsp;<input type="checkbox" name="m_multi_lang" id="m_multi_lang" value="Y" {if $module->m_multi_lang == 'Y'}checked{/if}><br>
		  <br><label for="m_create"><strong>Tạo model tự động</strong></label>&nbsp;<input type="checkbox" name="m_create" id="m_create" value="Y" {if $module->m_create == 'Y'}checked{/if}><br>
		  <br><strong>Module template :</strong>&nbsp;
		  <label for="m_template_add">
		  	<input type="checkbox" name="m_template_add" id="m_template_add" value="Y" {$addChk}>&nbsp;Thêm record
		  </label>
		  	&nbsp;
		  <label for="m_template_edit">
		  	<input type="checkbox" name="m_template_edit" id="m_template_edit" value="Y" {$editChk}>&nbsp;Chỉnh sửa
		  </label>
		  <br><br>
			<label for="m_upload_file"><strong>Module có upload file</strong> <input type="checkbox" name="m_upload_file" id="m_upload_file" value="Y" {if $module->m_upload_file == 'Y'}checked{/if}></label><br>
          <br><strong>Tên bảng </strong><em>(Không có refix)</em><br>
          <label class="smallInput">
            <input name="m_tbl_name" id="m_tbl_name" value="{$module->m_tbl_name|escape}" style="width: 168px;" type="text">
          </label>
		  <!-- table field  area -->
          {if $filed_count > 0}
            {foreach from=$field_info item=field name=infoPos}
              {if $smarty.foreach.infoPos.index == 0}<div id="formField">{else}<div id="formField{$smarty.foreach.infoPos.index+1}">{/if}
          <br><strong>Tên field :</strong><br>
            <ul style="display:block;">
              <li style="width:182px; float:left;">
                    <label class="smallInput">
                      <input type="text" name="field_name{$smarty.foreach.infoPos.index+1}" id="field_name{$smarty.foreach.infoPos.index+1}" value="{$field.field_name}">
                    </label>
                </li>
                <li style="width:120px; float:left;">
                    <select name="data_type{$smarty.foreach.infoPos.index+1}" id="data_type{$smarty.foreach.infoPos.index+1}">
                      <option value="-1">--DataType--</option>
                            <option value="tinyint" {if $field.data_type == 'tinyint'}selected{/if}>tinyint</option>
                            <option value="int" {if $field.data_type == 'int'}selected{/if}>int</option>
                            <option value="bigint" {if $field.data_type == 'bigint'}selected{/if}>bigint</option>
                            <option value="float" {if $field.data_type == 'float'}selected{/if}>float</option>
                            <option value="double" {if $field.data_type == 'double'}selected{/if}>double</option>
                            <option value="enum" {if $field.data_type == 'enum'}selected{/if}>enum</option>
                            <option value="varchar" {if $field.data_type == 'varchar'}selected{/if}>varchar</option>
                            <option value="text" {if $field.data_type == 'text'}selected{/if}>text</option>
                            <option value="longtext" {if $field.data_type == 'longtext'}selected{/if}>longtext</option>
                            <option value="blob" {if $field.data_type == 'blob'}selected{/if}>blob</option>
                            <option value="longblob" {if $field.data_type == 'longblob'}selected{/if}>longblob</option>
                            <option value="timestamp" {if $field.data_type == 'timestamp'}selected{/if}>timestamp</option>
                    </select>
                </li>
                <li style="width:103px; float:left;">
                  <input type="text" name="data_length{$smarty.foreach.infoPos.index+1}" id="data_length{$smarty.foreach.infoPos.index+1}" value="{if $field.data_length != ''}{$field.data_length|replace:'_':','}{else}--Length--{/if}" style="width:80px;" onfocus="this.value='';">
                <li>
                <li style="width:90px; float:left;">
              <input type="text" name="data_default{$smarty.foreach.infoPos.index+1}" id="data_default{$smarty.foreach.infoPos.index+1}" value="{if $field.data_default != ''}{$field.data_default|escape}{else}--Default value--{/if}" style="width:80px;" onfocus="this.value='';">
                <li>
                <li style="width:87px; float:left;">
                    <select name="primary{$smarty.foreach.infoPos.index+1}" id="primary{$smarty.foreach.infoPos.index+1}">
                      <option value="N">--PKey--</option>
                      <option value="N" {if $field.primary == 'N'}selected{/if}>No</option>
                      <option value="Y" {if $field.primary == 'Y'}selected{/if}>Yes</option>
                    </select>
                <li>
                <li style="width:70px; float:left;">
                    <select name="not_null{$smarty.foreach.infoPos.index+1}" id="not_null{$smarty.foreach.infoPos.index+1}">
                      <option value="Y">--Null--</option>
                      <option value="Y" {if $field.not_null == 'Y'}selected{/if}>Yes</option>
                      <option value="N" {if $field.not_null == 'N'}selected{/if}>No</option>
                    </select>
                <li>
            </ul>
            <ul style="display:block; padding-top:30px;">
                <li style="width:119px; float:left;">
                    <select name="unsigned{$smarty.foreach.infoPos.index+1}" id="unsigned{$smarty.foreach.infoPos.index+1}">
                      <option value="N">--Unsigned--</option>
                      <option value="Y" {if $field.unsigned == 'Y'}selected{/if}>Yes</option>
                      <option value="N" {if $field.unsigned == 'N'}selected{/if}>No</option>
                    </select>
                <li>
                <li style="width:115px; float:left;">
                    <select name="auto_incr{$smarty.foreach.infoPos.index+1}" id="auto_incr{$smarty.foreach.infoPos.index+1}">
                      <option value="N">--Auto Incr--</option>
                      <option value="Y" {if $field.auto_incr == 'Y'}selected{/if}>Yes</option>
                      <option value="N" {if $field.auto_incr == 'N'}selected{/if}>No</option>
                    </select>
                <li>
                <li style="width:190px; float:left;">
              <input type="text" name="command{$smarty.foreach.infoPos.index+1}" id="command{$smarty.foreach.infoPos.index+1}" value="{if $field.command != ''}{$field.command|escape}{else}--Command--{/if}" onfocus="this.value='';">
                <li>
            </ul>
            <ul style="display:block; padding-top:30px; padding-left:186px;">
              <li class="li_blue">Phần quản trị : Trang thêm - chỉnh sửa</li>
                    <li class="li_breen">Dạng field : <select name="fieldType{$smarty.foreach.infoPos.index+1}" id="fieldType{$smarty.foreach.infoPos.index+1}" onchange="showExpress('fieldType{$smarty.foreach.infoPos.index+1}', 'ckedit{$smarty.foreach.infoPos.index+1}', 'fieldsize{$smarty.foreach.infoPos.index+1}', 'fieldformat{$smarty.foreach.infoPos.index+1}')">
                                      <option value="-1">--Chọn dạnh field--</option>
									  <option value="CheckBox" {if $field.field_type == 'CheckBox'}selected{/if}>Checkbox</option>
                                      <option value="Text" {if $field.field_type == 'Text'}selected{/if}>Text</option>
                                      <option value="TextArea" {if $field.field_type == 'TextArea'}selected{/if}>TextArea</option>
                                      <option value="File" {if $field.field_type == 'File'}selected{/if}>File</option>
									  <option value="ParentId" {if $field.field_type == 'ParentId'}selected{/if}>Parent Id</option>
                    </select></li>
                    <li class="li_breen" {if $field.ckeditor == ''}style="display:none;"{/if} id="ckedit{$smarty.foreach.infoPos.index+1}">Sử dụng CKeditor : <label for="ckeditor{$smarty.foreach.infoPos.index+1}0"><input type="radio" name="ckeditor{$smarty.foreach.infoPos.index+1}" id="ckeditor{$smarty.foreach.infoPos.index+1}0" value="F" {if $field.ckeditor == 'F'}checked{/if}>&nbsp;Đầy đủ</label> <label for="ckeditor{$smarty.foreach.infoPos.index+1}1"><input type="radio" name="ckeditor{$smarty.foreach.infoPos.index+1}" id="ckeditor{$smarty.foreach.infoPos.index+1}1" value="S" {if $field.ckeditor == 'S'}checked{/if}>&nbsp; Đơn giản</label></li>
                    <li class="li_breen" {if $field.field_size == ''}style="display:none;"{/if} id="fieldsize{$smarty.foreach.infoPos.index+1}">Field size : <label for="field_size{$smarty.foreach.infoPos.index+1}0"><input type="radio" name="field_size{$smarty.foreach.infoPos.index+1}" id="field_size{$smarty.foreach.infoPos.index+1}0" value="smallInput" {if $field.field_size == 'smallInput'}checked{/if}>&nbsp;smallInput</label> <label for="field_size{$smarty.foreach.infoPos.index+1}1"><input type="radio" name="field_size{$smarty.foreach.infoPos.index+1}" id="field_size{$smarty.foreach.infoPos.index+1}1" value="mediumInput" {if $field.field_size == 'mediumInput'}checked{/if}>&nbsp;mediumInput</label></li>
					<li class="li_breen" {if $field.field_format == ''}style="display:none;"{/if} id="fieldformat{$smarty.foreach.infoPos.index+1}">File upload định dạng :
						<label for="field_img_format{$smarty.foreach.infoPos.index+1}"><input type="checkbox" name="field_img_format{$smarty.foreach.infoPos.index+1}" id="field_img_format{$smarty.foreach.infoPos.index+1}" value="img_format" {if preg_match("/img_format/", $field.field_format)}checked{/if}> Fil ảnh</label>&nbsp;
						<label for="field_media_format{$smarty.foreach.infoPos.index+1}"><input type="checkbox" name="field_media_format{$smarty.foreach.infoPos.index+1}" id="field_media_format{$smarty.foreach.infoPos.index+1}" value="media_format" {if preg_match("/media_format/", $field.field_format)}checked{/if}> File mp3/video</label><br>
						<label for="field_office_format{$smarty.foreach.infoPos.index+1}" style="padding-left:138px;"><input type="checkbox" name="field_office_format{$smarty.foreach.infoPos.index+1}" id="field_office_format{$smarty.foreach.infoPos.index+1}" value="office_format" {if preg_match("/office_format/", $field.field_format)}checked{/if}> File office</label>
					</li>
                    <li class="li_breen">Tiêu đề filed : <input type="text" name="field_title{$smarty.foreach.infoPos.index+1}" id="field_title{$smarty.foreach.infoPos.index+1}" value="{$field.field_title|escape}"></li>
            </ul>
                <ul style="display:block; padding-top:10px; padding-left:186px;">
                  <li class="li_blue">Phần quản trị : Trang quản lý</li>
                        <li class="li_breen">Sắp xếp : <input type="checkbox" name="field_sort{$smarty.foreach.infoPos.index+1}" id="field_sort{$smarty.foreach.infoPos.index+1}" value="Y" {if $field.field_sort == 'Y'}checked{/if}></li>
                </ul>
          </div>
            {/foreach}
          {else}
		  <div id="formField">
		  <br><strong>Tên field :</strong><br>
		  	<ul style="display:block;">
		  		<li style="width:182px; float:left;">
        		  	<label class="smallInput">
        		  		<input type="text" name="field_name1" id="field_name1" value="">
        		  	</label>
    		  	</li>
    		  	<li style="width:120px; float:left;">
        		  	<select name="data_type1" id="data_type1">
        		  		<option value="-1">--DataType--</option>
                        <option value="tinyint">tinyint</option>
                        <option value="int">int</option>
                        <option value="bigint">bigint</option>
                        <option value="float">float</option>
                        <option value="double">double</option>
                        <option value="enum">enum</option>
                        <option value="varchar">varchar</option>
                        <option value="text">text</option>
                        <option value="longtext">longtext</option>
                        <option value="blob">blob</option>
                        <option value="longblob">longblob</option>
                        <option value="timestamp">timestamp</option>
        		  	</select>
    		  	</li>
    		  	<li style="width:103px; float:left;">
    		  		<input type="text" name="data_length1" id="data_length1" value="--Length--" style="width:80px;" onfocus="this.value='';">
    		  	<li>
    		  	<li style="width:90px; float:left;">
					<input type="text" name="data_default1" id="data_default1" value="--Default value--" style="width:80px;" onfocus="this.value='';">
    		  	<li>
    		  	<li style="width:87px; float:left;">
        		  	<select name="primary1" id="primary1">
        		  		<option value="N">--PKey--</option>
        		  		<option value="N">No</option>
        		  		<option value="Y">Yes</option>
        		  	</select>
    		  	<li>
    		  	<li style="width:70px; float:left;">
        		  	<select name="not_null1" id="not_null1">
        		  		<option value="Y">--Null--</option>
        		  		<option value="Y">Yes</option>
        		  		<option value="N">No</option>
        		  	</select>
    		  	<li>
		  	</ul>
		  	<ul style="display:block; padding-top:30px;">
    		  	<li style="width:119px; float:left;">
        		  	<select name="unsigned1" id="unsigned1">
        		  		<option value="N">--Unsigned--</option>
        		  		<option value="Y">Yes</option>
        		  		<option value="N">No</option>
        		  	</select>
    		  	<li>
    		  	<li style="width:115px; float:left;">
        		  	<select name="auto_incr1" id="auto_incr1">
        		  		<option value="N">--Auto Incr--</option>
        		  		<option value="Y">Yes</option>
        		  		<option value="N">No</option>
        		  	</select>
    		  	<li>
    		  	<li style="width:190px; float:left;">
					<input type="text" name="command1" id="command1" value="--Command--" onfocus="this.value='';">
    		  	<li>
		  	</ul>
		  	<ul style="display:block; padding-top:30px; padding-left:186px;">
		  		<li class="li_blue">Phần quản trị : Trang thêm - chỉnh sửa</li>
                <li class="li_breen">Dạng field : <select name="fieldType1" id="fieldType1" onchange="showExpress('fieldType1', 'ckedit1', 'fieldsize1')">
                                  <option value="-1">--Chọn dạnh field--</option>
								  <option value="CheckBox">Checkbox</option>
                                  <option value="Text">Text</option>
                                  <option value="TextArea">TextArea</option>
                                  <option value="File">File</option>
								  <option value="ParentId">Parent Id</option>
                </select></li>
                <li class="li_breen" style="display:none;" id="ckedit1">Sử dụng CKeditor : <label for="ckeditor10"><input type="radio" name="ckeditor1" id="ckeditor10" value="F">&nbsp;Đầy đủ</label> <label for="ckeditor11"><input type="radio" name="ckeditor1" id="ckeditor11" value="S">&nbsp; Đơn giản</label></li>
                <li class="li_breen" style="display:none;" id="fieldsize1">Field size : <label for="field_size10"><input type="radio" name="field_size1" id="field_size10" value="smallInput">&nbsp;smallInput</label> <label for="field_size11"><input type="radio" name="field_size1" id="field_size11" value="mediumInput">&nbsp;mediumInput</label></li>
					<li class="li_breen" style="display:none;" id="fieldformat1">File upload định dạng :
						<label for="field_img_format1"><input type="checkbox" name="field_img_format1" id="field_img_format1" value="img_format"> Fil ảnh</label>&nbsp;
						<label for="field_media_format1"><input type="checkbox" name="field_media_format1" id="field_media_format1" value="media_format"> File mp3/video</label><br>
						<label for="field_office_format1" style="padding-left:138px;"><input type="checkbox" name="field_office_format1" id="field_office_format1" value="office_format"> File office</label>
					</li>
                <li class="li_breen">Tiêu đề filed : <input type="text" name="field_title1" id="field_title1" value=""></li>
		  	</ul>
            <ul style="display:block; padding-top:10px; padding-left:186px;">
              <li class="li_blue">Phần quản trị : Trang quản lý</li>
                    <li class="li_breen">Sắp xếp : <input type="checkbox" name="field_sort1" id="field_sort1" value="Y"></li>
            </ul>
		  </div>
          {/if}
          <div style="padding-left:180px;">
            <ul>
              <li><input type="button" name="" id="" value="Thêm field" onclick="javascript:ajaxLoadField();"></li>
            </ul>
          </div>
		  <!-- end of table field  area -->
		  <div style="clear:both;"></div>
		  <p>
			<label for="m_recursive"><strong>Module có cấu trúc đệ quy </strong>
				<input type="checkbox" name="m_recursive" id="m_recursive" value="Y" onclick="showHideParent()" {if $module->m_recursive == 'Y'}checked{/if}>
			</label>
		  </p>
		  <p id="TBL_PARENT" {if $module->m_recursive == 'N'}style="display:none;"{/if}>
			<strong>Field parent </strong><br>
			<label class="smallInput">
				<input name="tbl_parent_id" id="tbl_parent_id" value="{$module->tbl_parent_id}" style="width: 168px;" type="text">
		    </label>
		  </p>
		  <br><strong>ID chính của bảng</strong><br>
		  <label class="smallInput">
		  	<input name="tbl_pri_id" id="tbl_pri_id" value="{$module->tbl_pri_id}" style="width: 168px;" type="text">
		  </label>
		  <br><strong>Tên field chính của bảng</strong><br>
		  <label class="smallInput">
		  	<input name="tbl_pri_name" id="tbl_pri_name" value="{$module->tbl_pri_name}" style="width: 168px;" type="text">
		  </label>
		  <br><strong>Cấu trúc bảng của Module</strong><br>
		  <textarea rows="15" cols="90" name="m_tbl_struct" id="m_tbl_struct">{$module->m_tbl_struct}</textarea>
          </p>
          <br><strong>Giá trị mặc định</strong><br>
          <textarea rows="8" cols="90" name="m_default_val" id="m_default_val">{$module->m_default_val}</textarea>
            <input name="" src="{$base_media}/images/bt_submit.gif" onclick="return checkForm();" type="image">
          </p>
      </div>

</div>
<input name="m_id" id="m_id" value="{$modules_id}" type="hidden">
<input name="parent_id" id="parent_id" value="{$parent_id}" type="hidden">
<input name="total_field" id="total_field" value="{if $filed_count > 0}{$filed_count}{else}1{/if}" type="hidden">
</form>
</div>

<div id="sidebar" class="rightBoxes">
  <div class="rightBoxesTop">
    <h3>Chức năng<br></h3>
  </div>
  <div class="rightContent">
    <ul id="sidebarLinks">
      <li><a href="javascript:void(0);" onclick="javascript:executeCancel()">##SUBMIT_CANCEL##</a></li>
    </ul>
  </div>
</div>
<!-- end of #sidebar -->